<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
 public function index(){//显示首页
      $category=M('category');
     $catelist=$category->where('pid=0')->select();
     foreach ($catelist as $k=>$v)//对一级分类循环
         {
          $catelist[$k]['child']=fenlei($v['cid']);
       }
     $this->assign("catelist",$catelist);
  //获取推荐的商品，两个条件，回收站no，推荐标志为yes
    $best=M('goods');
  $bestlist=$best->where("recycle='no'and is_best='yes'")->select();
       $this->assign("bestlist",$bestlist);
      $this->display();
   }
  public function goods(){//显示商品的详细信息
    $gid=I("get.gid",0);
    $goods=M('goods');
    $goodslists=$goods->where("gid=$gid")->find();
    $this->assign("goodslists",$goodslists);//$lists是二维数组
    $this->display();
  }
}